# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=desktop-file-utils
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.26
pkgrel=2
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
pkgdesc="Utilities for .desktop files (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-ninja")
license=("LGPL 2.1")
url="https://www.gnome.org/"
source=(https://www.freedesktop.org/software/${_realname}/releases/desktop-file-utils-${pkgver}.tar.xz
        001-win.patch
        002-install.patch)
sha256sums=('b26dbde79ea72c8c84fb7f9d870ffd857381d049a86d25e0038c4cef4c747309'
            '477686cf08eaf80f5ee7f474cd6fb67361539f625c88fb9483ce600c5c8a73df'
            'd0fb777a741b3fbe1b92ae8b7855bbefb229e244c2c4a3af842f180e610f2fa1')

prepare() {
  cd ${_realname}-${pkgver}

  patch -b -V simple -p1 -i ${srcdir}/001-win.patch
  patch -b -V simple -p1 -i ${srcdir}/002-install.patch
}

build() {
  mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    meson \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --auto-features=enabled \
      --buildtype=plain \
      ../${_realname}-${pkgver}

  meson compile
}

package() {
  cd "$srcdir/build-${MSYSTEM}"

  DESTDIR="${pkgdir}" meson install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
